Release 10.1A: OpenEdge Application Server:
Developing AppServer Applications
Remote procedure code examples
This section presents AppServer-related code examples. The first example presents the code for a non-persistent procedure. The remaining two examples show two different ways to write code for the same remote persistent procedure.
Example 1: Remote non-persistent procedure example
This example shows how to run a remote, non-persistent procedure,
checkstk.p, on an AppServer identified ashAppSrv. TheTRANSACTIONDISTINCToption is used on theRUNstatement to specify that the client application’s transaction is not propagated tohAppSrv. The two temp-table parameters that are defined,ttOrderLineandttItem, are passed asINPUTandOUTPUTparameters, respectively, to thecheckstk.pprocedure, as shown:
When the
RUNstatement is executed, a remote procedure request to runcheckstk.pis sent to the AppServer instance that is connected via thehAppSrvserver handle. Once theRUNstatement is completed, this code checks to see ifcheckstk.pcompleted with anERRORcondition as would occur by executing theRETURNERRORstatement. Ifcheckstk.pdid execute theRETURNERRORstatement, then this code also returns with anERRORcondition. By using theRETURN-VALUEfunction, the code also returns the value returned bycheckstk.p.Example 2: Remote persistent procedure example
This code example shows how to instantiate a remote persistent procedure,
order.p, on an AppServer:
When the
RUNstatement fororder.pcompletes, a reference to the persistent procedure context is saved in handlehOrder. TheSERVERattribute forhOrdercontains a reference to the server handlehAppSrv. When the internal procedureGetExistingOrderis run for persistent procedurehOrder, OpenEdge uses the value ofhAppSrvto determine the AppServer instance where the persistent procedure is located.Example 3: Remote persistent procedure example using the FUNCTION statement
This example shows how a client application invokes a user-defined function,
GetExistingOrder, that is implemented remotely on an AppServer. It is presented as an alternative way to Example 2. TheFUNCTIONGetFirstOrderstatement in this example replaces the internal procedureGetExistingOrderreferenced in Example 2, as shown:
Like Example 2, when the
RUNstatement fororder.pcompletes, a reference to the persistent procedure context is saved in handlehOrder, and theSERVERattribute forhOrdercontains a reference to the server handlehAppSrv. However, instead of running an internal procedure, it runs the user-defined function,GetFirstOrder.For more information about creating user-defined functions, see the
Note: If a client application exits without executing theFUNCTIONStatement section in OpenEdge Development: Progress 4GL Reference .DISCONNECT( )method on the appropriate handles, OpenEdge automatically disconnects the client from the AppServer. This automatic disconnection can also occur if the AppServer machine looses network connectivity with the client application. This can happen, for example, if there is a network failure.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |